`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    20:10:11 03/31/2014 
// Design Name: 
// Module Name:    debouncer 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module debouncer(signal_out, push_button, clk);
input push_button, clk;
output reg signal_out = 0;

reg [15:0] cycles = 0;

parameter DELAY_CYCLES = 50000;

always @(posedge clk)
    if(!push_button)
        begin
            signal_out <= 1'b0;
            cycles <= 32'd0;
        end
    else if(cycles == DELAY_CYCLES)
        signal_out <= 1'b1;
    else
        cycles <= cycles + 16'd1;
endmodule

